package com.ruoyi.web.controller.system;

import java.util.List;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;
import javax.validation.constraints.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.vo.SysPtExpVideoVo;
import com.ruoyi.system.bo.SysPtExpVideoQueryBo;
import com.ruoyi.system.bo.SysPtExpVideoAddBo;
import com.ruoyi.system.bo.SysPtExpVideoEditBo;
import com.ruoyi.system.service.ISysPtExpVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 实验视频管理Controller
 *
 * @author ruoyi
 * @date 2021-11-28
 */
@Api(value = "实验视频管理控制器", tags = {"实验视频管理管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/system/SysVideo")
public class SysPtExpVideoController extends BaseController {

    private final ISysPtExpVideoService iSysPtExpVideoService;

    /**
     * 查询实验视频管理列表
     */
    @ApiOperation("查询实验视频管理列表")
    @PreAuthorize("@ss.hasPermi('system:SysVideo:list')")
    @GetMapping("/list")
    public TableDataInfo<SysPtExpVideoVo> list(@Validated SysPtExpVideoQueryBo bo) {
        return iSysPtExpVideoService.queryPageList(bo);
    }

    /**
     * 导出实验视频管理列表
     */
    @ApiOperation("导出实验视频管理列表")
    @PreAuthorize("@ss.hasPermi('system:SysVideo:export')")
    @Log(title = "实验视频管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult<SysPtExpVideoVo> export(@Validated SysPtExpVideoQueryBo bo) {
        List<SysPtExpVideoVo> list = iSysPtExpVideoService.queryList(bo);
        ExcelUtil<SysPtExpVideoVo> util = new ExcelUtil<SysPtExpVideoVo>(SysPtExpVideoVo.class);
        return util.exportExcel(list, "实验视频管理");
    }

    /**
     * 获取实验视频管理详细信息
     */
    @ApiOperation("获取实验视频管理详细信息")
    @PreAuthorize("@ss.hasPermi('system:SysVideo:query')")
    @GetMapping("/{videoId}")
    public AjaxResult<SysPtExpVideoVo> getInfo(@NotNull(message = "主键不能为空")
                                                  @PathVariable("videoId") Long videoId) {
        return AjaxResult.success(iSysPtExpVideoService.queryById(videoId));
    }

    /**
     * 新增实验视频管理
     */
    @ApiOperation("新增实验视频管理")
    @PreAuthorize("@ss.hasPermi('system:SysVideo:add')")
    @Log(title = "实验视频管理", businessType = BusinessType.INSERT)
    @PostMapping()
    public AjaxResult<Void> add(@Validated @RequestBody SysPtExpVideoAddBo bo) {
        return toAjax(iSysPtExpVideoService.insertByAddBo(bo) ? 1 : 0);
    }

    /**
     * 修改实验视频管理
     */
    @ApiOperation("修改实验视频管理")
    @PreAuthorize("@ss.hasPermi('system:SysVideo:edit')")
    @Log(title = "实验视频管理", businessType = BusinessType.UPDATE)
    @PutMapping()
    public AjaxResult<Void> edit(@Validated @RequestBody SysPtExpVideoEditBo bo) {
        return toAjax(iSysPtExpVideoService.updateByEditBo(bo) ? 1 : 0);
    }

    /**
     * 删除实验视频管理
     */
    @ApiOperation("删除实验视频管理")
    @PreAuthorize("@ss.hasPermi('system:SysVideo:remove')")
    @Log(title = "实验视频管理" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{videoIds}")
    public AjaxResult<Void> remove(@NotEmpty(message = "主键不能为空")
                                       @PathVariable Long[] videoIds) {
        return toAjax(iSysPtExpVideoService.deleteWithValidByIds(Arrays.asList(videoIds), true) ? 1 : 0);
    }
}
